/* nixonFTP
 * FTP client version 0.1
 * Copyright (C) 2010 NIXON Development Corporation.
 * All rights reserved.
 * http://members.shaw.ca/nixon.com
*/

package nixonftp.ui;

import nixonftp.*;
import javax.swing.ImageIcon;
import javax.swing.JMenu;
import javax.swing.JMenuItem;

/**
 *
 * @author Billy
 */
public class NXContextMenu extends NXMenu {
	private JMenu deleteMenu;
	public JMenuItem switchView;
	public NXTraverseMenu transferTo;
	private NXMenuItem transfer;
	private NXMenuItem preview;
	
	public NXContextMenu() {
		super();
		this.addImpl("New Folder In", "NewFolderIn", NXIcon.addFolder);
		this.addImpl("New Folder", "NewFolder", NXIcon.addFolder);
		this.addSeparator("top");
		this.addImpl("Reload", "Reload", null);
		switchView = this.addImpl("Switch View", "SwitchView", NXIcon.detail);

		this.addSeparator("middle");

		this.addImpl("Details...", "Details", null);
		this.addImpl("Rename", "Rename", null);

		String s = "Delete";
		deleteMenu = new JMenu(s);
		NXMenuItem item = new NXMenuItem(s, s);
		item.setActionCommand(s);
		item.setIcon(NXIcon.trash);
		deleteMenu.add(item);
		addMenu(deleteMenu, NXIcon.trash);

		preview = this.addImpl("Preview", "Preview", null);
		this.addImpl("Open", "Open", null);

		transferTo = new NXTraverseMenu("Transfer To", "", true);
		addMenu(transferTo, null);
		addToIndex("TransferTo", transferTo);

		transfer = addImpl("Transfer", "Transfer", null);
	}

	public void setLocal(boolean local) {
		String strTransfer = (local) ? "Upload" : "Download";
		ImageIcon transferIcon = (local) ? NXIcon.upload : NXIcon.download;
		transfer.setIcon(transferIcon);
		transferTo.setIcon(transferIcon);
		transferTo.setText(strTransfer + " To");
	}

	public JMenu getDeleteMenu() {
		return deleteMenu;
	}

	public void switchView(boolean list) {
		switchView.setText((list) ? "Columns View" : "Detailed View");
		switchView.setIcon((list) ? NXIcon.columns : NXIcon.detail);
	}

}



